home *** CD-ROM | disk | FTP | other *** search
/ WINMX Assorted Textfiles / Ebooks.tar / Text - Tech - Programming - Assembly - Tutorial for Beginners (TXT).zip / Very Basic Assembly tutorial for Beginners.txt
Text File  |  1998-07-27  |  6KB  |  185 lines

  1. Assembly for Crackers - v1.0
  2. ----------------------------
  3.  
  4. Hey, This is a very basic guide to assembly for all those people who couldn't be bothered learning the in's & out's of their computer just to be able to use mIRC without having to click on some guys face. :)
  5.  
  6. I'll basically go through the most necessary stuff that you need to know before you can begin to crack. I know it's not in a very logical order, but what d'ya want for free? ;))
  7.  
  8. Oh yeah, you should view this with wordwrap on, otherwise it'll be a pain in the arse to follow ;)
  9.  
  10.  
  11. REGISTERS
  12. ---------
  13.  
  14. Registers are basically default places in which to store data. The only ones we need to worry about are: (E)AX,(E)BX,(E)CX,(E)DX
  15. ( The (E) is only significant when debugging 32-bit code ) 
  16.  
  17. Also the register pairs:
  18. DS:SI    ; Can be used as the source for string operations
  19. ES:DI   ; Used as the target for string operations
  20.  
  21. To understand registers isn't very important for cracking, generally just to know that they're variables for data storage is enough to get you started :)
  22.  
  23.  
  24.  
  25. FLAGS
  26. -----
  27.  
  28. Flags are essentially like registers except that they can only be true or false ( ie 0 or 1 ) These are set by commands such as CMP, and are used to check the outcome of such a call, ie:
  29.  
  30. CMP   AX, BX    ; Compare AX to BX, if equal the zero flag is set to 1
  31. JZ    00124531    ; If the zero flag is set, jump to 001254531.
  32.  
  33. To understand this properly you'll probably have to read on and then come back... :P
  34.  
  35.  
  36.  
  37. The Stack & Push/Pop
  38. --------------------
  39.  
  40. Before any function call, a program must 'push' any parameters that the function expects onto the stack. Think of it as a stack of plates, the first plate on the stack is the last one to be taken off-- the stack is exactly the same.  It's important to remember this 'first on/last off' principal when looking at a call, as this means that the parameters will be  passed in reverse order...
  41.  
  42. In case my babbling has confused you, lets look at this example:
  43.  
  44.  
  45. The windows api function GetDlgItemText requires the following parameters:
  46.  
  47. (1) Handle of dialog box
  48. (2) Identifier of control
  49. (3) Address of buffer for text
  50. (4) Maximum size of string
  51.  
  52. Therefore these could be passed like so:
  53.  
  54. MOV  EDI,[ESP+00000220]        ; Get Handle of dialog box in EDI
  55. PUSH 00000100            ; PUSH (4) Max size of string
  56. PUSH 00406130            ; PUSH (3) Address of buffer for text
  57. PUSH 00000405            ; PUSH (2) Identifier of control
  58. PUSH EDI            ; PUSH (1) Handle of dialog box
  59. CALL GetWindowText        ; CALL the function
  60.  
  61. Easy eh? This can be one of the simplest ways of cracking a serial number app, if you know the address of the buffer for the serial number, in this case 00406130, just breakpoint it, and you'll usually end up in or around the procedure that generates the real serial!! :)
  62.  
  63. POP is simply used to remove the first item from the stack, there are usually a lot of them before a function returns to the program...
  64.  
  65.  
  66.  
  67. AND
  68. ---
  69.  
  70. USAGE   : AND dest,src
  71. PURPOSE : Performs a logical AND of the two inputs, replacing the dest with the result
  72. EXAMPLE : AND BX, 03h
  73.  
  74. There's not very much that can be said about this call, it does what it says.
  75.  
  76.  
  77.  
  78. CALL
  79. ----
  80.  
  81. USAGE   : CALL address
  82. PURPOSE : Executes a function at the address 'address'
  83. EXAMPLE : CALL 10284312
  84.  
  85. Calls the function at address 'address', once the function has finished, the code with continue the line after the call.
  86.  
  87.  
  88.  
  89. CMP
  90. ---
  91.  
  92. USAGE   : CMP dest,src
  93. PURPOSE : Subtracts src from dest and updates the flags.
  94. EXAMPLE : CMP AX,03h
  95.  
  96. This is an important instruction as far as we ( crackers ) are concerned :). Somewhere in the program for it to verify something, ie. to compare the real serial to the one we enter, or to check if a program is registered etc. 
  97.  
  98. This instruction usually preceeds a jump instruction of some kind.
  99.  
  100.  
  101.  
  102. INT
  103. ---
  104.  
  105. USAGE   : INT interrupt_number
  106. PURPOSE : Calls a default function ( usually coded in the BIOS )
  107. EXAMPLE : INT 10h
  108.  
  109. You won't really see this command much ( if at all ) when debugging windows programs, but they turn up all over the place in DOS. Usually the parameters are passed in the default registers ( AX,BX,CX etc. )
  110.  
  111. There are far too many INT calls to list here, better to get a copy of an interrupt list. Ralph Browns is very good! :)
  112.  
  113.  
  114.  
  115. JMP
  116. ---
  117.  
  118. USAGE   : JMP address
  119. PURPOSE : Equivalent to a basic GOTO, jumps to a section of code
  120. EXAMPLE : JMP 00402011
  121.  
  122. JMP is an unconditional jump to a section of code. As simple as that! :) 
  123.  
  124. There are tons of variations on this instruction, the most important ones are:
  125.  
  126. JZ   - Jump if the zero flag is set. ( Same as JE )
  127. JNZ  - Jump if the zero flag is not set. ( Same as JNE )
  128.  
  129. These usually follow a CMP instruction, ie:
  130.  
  131. CMP    RealSerial,BadSerial    ; Compare the real serial to our serial
  132. JNE    GoAwayBadCracker        ; If Not Equal then exit.
  133.     
  134.  
  135.  
  136. MOV
  137. ---
  138.  
  139. USAGE   : MOV dest,src
  140. PURPOSE : Copies byte or word value from the source to the destination
  141. EXAMPLE : MOV AX,DX
  142.  
  143. You will see this a *lot* when you're stepping through code, it basically means ( to use BASIC terms ;) ) LET dest = src
  144.  
  145. There are quite a few variants including MOVSX, but they all basically do the same thing. It might help to get the intel programming specs from their website.
  146.  
  147. If you can't understand this one, you're screwed! ;)
  148.  
  149.  
  150.  
  151. OR
  152. --
  153.  
  154. USAGE   : OR dest,src
  155. PURPOSE : Performs a logical OR on the two inputs replacing the dest with the result
  156. EXAMPLE : OR DX, AX
  157.  
  158. Does what it says.
  159.  
  160.  
  161.  
  162. RET
  163. ---
  164.  
  165. USAGE    : RET
  166. PURPOSE : To return from a function
  167. EXAMPLE : RET
  168.  
  169. You will usually see this at the end of a function, and it simply instructs the processor to return to the address of the call to the function.
  170.  
  171.  
  172.  
  173. Useful Stuff
  174. ------------
  175.  
  176. The specs for programming intel processors : www.intel.com
  177. Ralph Browns interrupt list           : search for it
  178. Win32 Programmers Reference           : comes with any visual language
  179.  
  180.  
  181. As far as I know this is about all you'll need to really understand to get started in cracking. Most of the stuff is pretty self-explanitory, but if you get stuck you can email me at: Corn02@hotmail.com or go to #cracking4newbies on efnet, where you'll be able to find someone to help you out. Any comments and stuff are also welcome, or any stuff that you think needs to be added also.
  182.  
  183. --Corn2
  184.  
  185.